using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Simnova.Collaborate.Presenter;
using Simnova.Collaborate.View;

public partial class _Default : System.Web.UI.Page, ILogin 
{
    private LoginPresenter _loginPresenter;

    protected void Page_Load(object sender, EventArgs e)
    {
        this._loginPresenter = new LoginPresenter(this);
    }
    protected void LoginButton_Click(object sender, EventArgs e)
    {
        int userId = 0;
        try
        {
            LoginValidator.ErrorMessage = "";
            userId = this._loginPresenter.Login();
        }
        catch (Exception ex)
        {
            if (ex.Message == "Login Failed")
            {
                LoginValidator.ErrorMessage = "Login Failed";
                LoginValidator.Enabled = true;
            }
            else
            {
                throw;
            }
            return;
        }
        Session["UserId"] = userId;
        Response.Redirect(@"~\FeedbackOverview.aspx", true);
    }

    #region ILogin Members

    string ILogin.EmailAddress
    {
        get
        {
            return EmailAddressTextBox.Text;
        }
        set
        {
            EmailAddressTextBox.Text = value;
        }
    }

    string ILogin.Password
    {
        get
        {
            return PasswordTextBox.Text;
        }
        set
        {
            PasswordTextBox.Text = value;
        }
    }

    #endregion
}
